var $dataChart;
var dataChart;
require(['grid', 'topBar', 'layout','date'], function () {
	var carIds="";//左侧树状图选中的车辆id
    $('body').layout();
    $('#top').topBar({       
        left: [{
                   type: 'filter-more',
                   dateType:'custom',
                   search: function () {
					},
                   item: [
                       {
                           text: '时间快捷',
                           name1: 'beginTime',
                           name2: 'endTime',
                           type: 'dateLine'
                       }
                   ]
               }],
        right: [
            {
                text: '导出',
                type: 'export-btn',
                authority: '',
                item: [
                    {
                        text: 'Excel导出',
                        click: function () {
                        }
                    },
                    {
                        text: 'PDF导出',
                        click: function () {
                        }
                    }
                ]
            },
            {
                text: '轮胎寿命预测',
                type: 'btn',
                authority: '',
                click: function () {
                	dataChart('轮胎寿命预测');
                }
            }
        ]
    });

    $('#grid').grid({  
		multiselect:false,
	    data:[
				{rcrdId:"1",beginLoLgt:"A647",beginLoLtt:"泉州二公司",beginLoDrc:"米其林",licPltNo:"翻胎",lineName:"295/80R22.5",organName:"轮胎1",mftGradeName:"1.5",ecuMftName:"5",mftTypeName:"3.5",spdOfMotVhi:"轻度",status:"10"},
				{rcrdId:"1",beginLoLgt:"A647",beginLoLtt:"泉州二公司",beginLoDrc:"米其林",licPltNo:"翻胎",lineName:"295/80R22.5",organName:"轮胎2",mftGradeName:"4.5",ecuMftName:"8.3",mftTypeName:"7.0",spdOfMotVhi:"一般",status:"1"},
				{rcrdId:"1",beginLoLgt:"A647",beginLoLtt:"泉州二公司",beginLoDrc:"米其林",licPltNo:"翻胎",lineName:"295/80R22.5",organName:"轮胎3",mftGradeName:"4.5",ecuMftName:"6",mftTypeName:"7.0",spdOfMotVhi:"严重",status:"3"},
				{rcrdId:"1",beginLoLgt:"A647",beginLoLtt:"泉州二公司",beginLoDrc:"米其林",licPltNo:"翻胎",lineName:"295/80R22.5",organName:"轮胎4",mftGradeName:"4.5",ecuMftName:"5.5",mftTypeName:"7.0",spdOfMotVhi:"严重",status:"4"},
				{rcrdId:"1",beginLoLgt:"A647",beginLoLtt:"泉州二公司",beginLoDrc:"米其林",licPltNo:"翻胎",lineName:"295/80R22.5",organName:"轮胎5",mftGradeName:"4.5",ecuMftName:"8.2",mftTypeName:"7.0",spdOfMotVhi:"一般",status:"1"},
				{rcrdId:"1",beginLoLgt:"A647",beginLoLtt:"泉州二公司",beginLoDrc:"米其林",licPltNo:"翻胎",lineName:"295/80R22.5",organName:"轮胎6",mftGradeName:"4.5",ecuMftName:"9.4",mftTypeName:"7.0",spdOfMotVhi:"轻度",status:"0"}
			],
		colModel : [
            {name : "rcrdId",label: 'id',key : true,hidden : true},
			{name : "beginLoLgt",label: '车辆'},
			{name : "beginLoLtt",label: '公司'},
			{name : "beginLoDrc",label: '品牌'},
			{name : "licPltNo",label: '类型'},
			{name : "lineName",label: '规格'},
			{name : "organName",label: '轮胎位置'},
			{name : "mftGradeName",label: '已用周期(万公里)',align : "right"},
			{name : "ecuMftName",label: '预测周期(万公里)',align : "right"},
			{name : "mftTypeName",label: '计划保养周期(万公里)',align : "right"},
			{name : "spdOfMotVhi",label: '磨损度',align : "right"},
			{name : "status",label: '漏气次数',align : "right"},
			{name: "num", label: '保养次数',index: "num",align : "right",
                formatter:function (cellvalue, options, rowObject){
                    return "<a href='javascript:void(0)'style='color: blue;'onclick=dataChart('保养次数')>22</a>";
                }},
			{name: "operate", label: '操作',index: "operate",formatter: 'operArea',
				formatoptions: [
	                {
	                    text: '轮胎分析图',
                        css: 'operate-scan',
	                    click: function (data) {
	                    	dataChart('轮胎分析图');
	                    }
	                }
				]
			}]
	});

    dataChart=function(title){
    	if(!$dataChart){    		
    		$dataChart= $('<div>').dialog({
                    url: './mainte/report/viewDataChart.htm',
        	        height: 550,
        	        width: 720,
        	        buttons:[
	                 {
	                     text: '关闭',
	                     css: 'btn-cancel',
	                     click: function () {
	                    	 $dataChart.dialog('close');
	                     }
	                 }
                 ]
                });
    	}        
            	
    	if(title=='轮胎寿命预测'){
    		$dataChart.dialog('exec', 'tireLifeForecast');
    	}
    	else	if(title=='轮胎分析图'){
    		$dataChart.dialog('exec', 'tireAnalyChart');
    	}
    	else 	if(title=='保养次数'){
    		$dataChart.dialog('exec', 'tireMaintainingTimes');
    	}   
    	$dataChart.dialog('setOption','title',title);
    	$dataChart.dialog('open');
    }
    
})
